package 力扣.二叉树相关问题.n叉树;

import java.util.LinkedList;
import java.util.List;

public class n叉树的前序遍历 {
    class Node {
        public int val;
        public List<Node> children;
        public Node() {}
        public Node(int _val) {
            val = _val;
        }
        public Node(int _val, List<Node> _children) {
            val = _val;
            children = _children;
        }
    };
    List<Integer> list = new LinkedList<>();
    public List<Integer> preorder(Node root) {
       if (root==null)
           return list;
       list.add(root.val);
       for (Node child : root.children) {
            preorder(child);
        }
        return list;
    }
}
